namespace QMVnSoft.SystemForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class FormAttachDatabase : FormControl
    {
        private BtnControl btnCancel;
        private BtnControl btnLDFFile;
        private BtnControl btnMDFFile;
        private BtnControl btnOk;
        private IContainer components;
        private bool ib_CheckAccepted;
        private string is_LDFStringFile;
        private string is_MDFStringFile;
        private LabelControl labelControl1;
        private LabelControl lblLDFFile;
        private LabelControl lblMDFFile;
        private TextControl txtLDFFile;
        private TextControl txtMDFFile;

        public FormAttachDatabase()
        {
            this.InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnLDFFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.InitialDirectory = "";
            dialog.Filter = "LDF file (*.ldf)|*.ldf";
            dialog.CheckFileExists = true;
            dialog.ShowDialog();
            this.txtLDFFile.Text = dialog.FileName;
        }

        private void btnMDFFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.InitialDirectory = "";
            dialog.Filter = "MDF file (*.mdf)|*.mdf";
            dialog.CheckFileExists = true;
            dialog.ShowDialog();
            this.txtMDFFile.Text = dialog.FileName;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!File.Exists(this.txtMDFFile.Text) || !File.Exists(this.txtLDFFile.Text))
            {
                MessageBox.Show("Đường dẫn dữ liệu không chính xác!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                this.CheckAccepted = true;
                this.MDFStringFile = this.txtMDFFile.Text;
                this.LDFStringFile = this.txtLDFFile.Text;
                base.Close();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormAttachDatabase));
            this.btnCancel = new BtnControl();
            this.btnOk = new BtnControl();
            this.txtLDFFile = new TextControl();
            this.lblMDFFile = new LabelControl();
            this.btnLDFFile = new BtnControl();
            this.txtMDFFile = new TextControl();
            this.btnMDFFile = new BtnControl();
            this.lblLDFFile = new LabelControl();
            this.labelControl1 = new LabelControl();
            base.SuspendLayout();
            //this.btnCancel.DialogResult = DialogResult.Cancel;
            this.btnCancel.Font = new Font("Arial", 8.25f);
            this.btnCancel.Location = new Point(0xb3, 0xaf);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(120, 0x17);
            this.btnCancel.TabIndex = 5;
            this.btnCancel.Text = "&Huỷ bỏ";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnOk.Font = new Font("Arial", 8.25f);
            this.btnOk.Location = new Point(0x35, 0xaf);
            this.btnOk.Name = "btnOk";
            this.btnOk.Size = new Size(120, 0x17);
            this.btnOk.TabIndex = 4;
            this.btnOk.Text = "&Thực hiện";
            this.btnOk.UseVisualStyleBackColor = true;
            this.btnOk.Click += new EventHandler(this.btnOk_Click);
            this.txtLDFFile.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtLDFFile.CheckTextSearched = false;
            this.txtLDFFile.DisabledForeColor = Color.Blue;
            this.txtLDFFile.Font = new Font("Arial", 8.25f);
            this.txtLDFFile.Location = new Point(0x4e, 80);
            this.txtLDFFile.Name = "txtLDFFile";
            this.txtLDFFile.OldValue = null;
            this.txtLDFFile.Size = new Size(0xe3, 20);
            this.txtLDFFile.TabIndex = 2;
//            //this.txtLDFFile.Value = null;//manager.GetObject("txtLDFFile.Value");
            this.lblMDFFile.AutoSize = true;
            this.lblMDFFile.Font = new Font("Arial", 8.25f);
            this.lblMDFFile.Location = new Point(12, 0x39);
            this.lblMDFFile.Name = "lblMDFFile";
            this.lblMDFFile.Size = new Size(60, 14);
            this.lblMDFFile.TabIndex = 9;
            this.lblMDFFile.Text = "Tệp dữ liệu";
            this.btnLDFFile.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnLDFFile.Font = new Font("Arial", 8.25f);
            this.btnLDFFile.Location = new Point(0x137, 0x4f);
            this.btnLDFFile.Name = "btnLDFFile";
            this.btnLDFFile.Size = new Size(30, 0x16);
            this.btnLDFFile.TabIndex = 3;
            this.btnLDFFile.Text = "...";
            this.btnLDFFile.UseVisualStyleBackColor = true;
            this.btnLDFFile.Click += new EventHandler(this.btnLDFFile_Click);
            this.txtMDFFile.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtMDFFile.CheckTextSearched = false;
            this.txtMDFFile.DisabledForeColor = Color.Blue;
            this.txtMDFFile.Font = new Font("Arial", 8.25f);
            this.txtMDFFile.Location = new Point(0x4e, 0x36);
            this.txtMDFFile.Name = "txtMDFFile";
            this.txtMDFFile.OldValue = null;
            this.txtMDFFile.Size = new Size(0xe3, 20);
            this.txtMDFFile.TabIndex = 0;
//            //this.txtMDFFile.Value = null;//manager.GetObject("txtMDFFile.Value");
            this.btnMDFFile.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnMDFFile.Font = new Font("Arial", 8.25f);
            this.btnMDFFile.Location = new Point(0x137, 0x36);
            this.btnMDFFile.Name = "btnMDFFile";
            this.btnMDFFile.Size = new Size(30, 0x16);
            this.btnMDFFile.TabIndex = 1;
            this.btnMDFFile.Text = "...";
            this.btnMDFFile.UseVisualStyleBackColor = true;
            this.btnMDFFile.Click += new EventHandler(this.btnMDFFile_Click);
            this.lblLDFFile.AutoSize = true;
            this.lblLDFFile.Font = new Font("Arial", 8.25f);
            this.lblLDFFile.Location = new Point(12, 0x53);
            this.lblLDFFile.Name = "lblLDFFile";
            this.lblLDFFile.Size = new Size(60, 14);
            this.lblLDFFile.TabIndex = 8;
            this.lblLDFFile.Text = "Tệp lịch sử";
            this.labelControl1.BorderStyle = BorderStyle.Fixed3D;
            this.labelControl1.Font = new Font("Arial", 8.25f);
            this.labelControl1.Location = new Point(15, 0x9d);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x146, 2);
            this.labelControl1.TabIndex = 8;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.CancelButton = this.btnCancel;
            base.ClientSize = new Size(0x161, 210);
            base.Controls.Add(this.txtLDFFile);
            base.Controls.Add(this.lblMDFFile);
            base.Controls.Add(this.btnLDFFile);
            base.Controls.Add(this.txtMDFFile);
            base.Controls.Add(this.btnMDFFile);
            base.Controls.Add(this.labelControl1);
            base.Controls.Add(this.lblLDFFile);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnOk);
            ////base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FormAttachDatabase";
            base.ShowInTaskbar = false;
            this.Text = "Tệp dữ liệu để gắn cơ sở dữ liệu";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public bool CheckAccepted
        {
            get
            {
                return this.ib_CheckAccepted;
            }
            set
            {
                this.ib_CheckAccepted = value;
            }
        }

        public string LDFStringFile
        {
            get
            {
                return this.is_LDFStringFile;
            }
            set
            {
                this.is_LDFStringFile = value;
            }
        }

        public string MDFStringFile
        {
            get
            {
                return this.is_MDFStringFile;
            }
            set
            {
                this.is_MDFStringFile = value;
            }
        }
    }
}

